//
//  BaseTableViewController.swift
//  WeiBo09
//
//  Created by 裘明 on 15/8/31.
//  Copyright © 2015年 qm. All rights reserved.
//

import UIKit

class BaseTableViewController: UITableViewController {
    
    /// 用户登录信息标记
    var userLogin = UserAccountViewModel.sharedUserAccount.userLogin
    
    var vistorLogin: VistorLoginView?
    
    override func loadView() {
        
        userLogin ? super.loadView() : setupVistorView()
    }
    
    private func setupVistorView() {
        
        vistorLogin = VistorLoginView()
        view = vistorLogin
        
        self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorLoginViewWillRegister")
        self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorLoginViewWillLogin")
        
        vistorLogin?.registerBtn.addTarget(self, action: "visitorLoginViewWillRegister", forControlEvents: UIControlEvents.TouchUpInside)
        vistorLogin?.loginBtn.addTarget(self, action: "visitorLoginViewWillLogin", forControlEvents: UIControlEvents.TouchUpInside)
        
    }
    @objc private func visitorLoginViewWillRegister(){
        
        printLog(__FUNCTION__)
        
    }
    
    @objc private func visitorLoginViewWillLogin(){

        let nav = UINavigationController(rootViewController: OAuthViewController())
        presentViewController(nav, animated: true, completion: nil)
        
    }

}
